package com.example.administrator.qq;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.Switch;

/**
 * Created by ykbboom on 2016/12/29.
 */
public class SettingActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        Switch switchMusic = (Switch) findViewById(R.id.switch1);
        //设置状态改变事件
        switchMusic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){//选中
                    startService(new Intent("com.angel.Android.MUSIC"));
                }else{//未选中
                    stopService(new Intent("com.angel.Android.MUSIC"));
                }
            }
        });
    }
}
